﻿@model Models.Users

@{
    Layout = null;
    ViewData["Title"] = "用户编辑";
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <title>@ViewData["Title"]</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <environment include="Development">
        <link rel="stylesheet" href="~/layer/css/layui.css" media="all" />
        <link rel="stylesheet" href="~/layer/css/admin.css" media="all" />
    </environment>
    <environment exclude="Development">
        <link rel="stylesheet" href="~/layer/css/layui.css" asp-append-version="true" media="all" />
        <link rel="stylesheet" href="~/layer/css/admin.css" asp-append-version="true" media="all" />
    </environment>
</head>
<body id="iosiframe">
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">用户编辑</div>
                    <div class="layui-card-body" pad15>
                        <form class="layui-form" action="" lay-filter="component-form-element">
                            <div class="layui-form-item" style="display:none;">
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label">用户编号：</label>
                                    <div class="layui-input-block">
                                        <input type="text" asp-for="UserCode" maxlength="8" readonly lay-verify="" placeholder="" autocomplete="off" class="layui-input" />
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label">姓名：</label>
                                    <div class="layui-input-block">
                                        <input type="text" maxlength="20" asp-for="UserName" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label">联系手机：</label>
                                    <div class="layui-input-block">
                                        <input type="text" maxlength="18" asp-for="Phone" placeholder="" lay-verify="required|phone" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label">身份证：</label>
                                    <div class="layui-input-block">
                                        <input type="text" maxlength="18" asp-for="IdCard" placeholder="" lay-verify="required|identity" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label"></label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid">初始密码为：<b style="color:#b40e0e">123456</b></div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit="" lay-filter="component-form-element">立即提交</button>
                                    <a class="layui-btn  layui-btn-primary" lay-filter="component-form-element" href="@Url.Action("recommendlist","account")">返回</a>
                                </div>
                            </div>

                            @if (Model != null) {
                                <input type="hidden" asp-for="Id" />
                                <input type="hidden" asp-for="SecondaryPwd" />
                                <input type="hidden" asp-for="Overage" />
                                <input type="hidden" asp-for="CreateTime" />
                                <input type="hidden" asp-for="UserType" />
                                <input type="hidden" asp-for="Password" />
                                <input type="hidden" asp-for="ProvinceId" />
                                <input type="hidden" asp-for="CityId" />
                                <input type="hidden" asp-for="Level" />
                                <input type="hidden" asp-for="ParentId" />
                            }
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="~/layer/layui.js"></script>
    <script>
        layui.config({
            base: '../../layer/' //静态资源所在路径
        }).extend({
            index: 'index' //主入口模块
        }).use(['form'], function () {
            var $ = layui.$
                , form = layui.form;

            var ua = navigator.userAgent.toLowerCase();
            var screenwidth = window.screen.width;
            if (!/iphone|ipad|ipod/.test(ua)) {
                $("#iosiframe").attr("scrolling", "auto");
            } else {
                $('#iosiframe').width(screenwidth + 'px');
            }

            form.render(null, 'component-form-element');

            //提交
            form.on('submit(component-form-element)', function (data) {
                $.ajax({
                    url: '@Url.Action("saverecommend", "api")',
                    dataType: 'json',
                    contentType: 'application/json',
                    data: JSON.stringify(data.field),
                    type:'post'
                }).fail(function (jqXHR, textStatus, errorThrown) {
                    window.parent.tools.alert(errorThrown, { icon: 2, title: textStatus });
                }).done(function (res) {
                    window.parent.tools.alert(res.message, (res.code == 0 ? 1 : 2), function () {
                        if (res.code == 0) {
                            location.href = '@Url.Action("recommendlist", "account")';
                        }
                    });
                });
                return false;
            });

        });

    </script>
</body>
</html>
